package com.lxmes.business.controller;

import java.util.List;
import javax.servlet.http.HttpServletResponse;

import com.lxmes.common.utils.SecurityUtils;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.lxmes.common.annotation.Log;
import com.lxmes.common.core.controller.BaseController;
import com.lxmes.common.core.domain.AjaxResult;
import com.lxmes.common.enums.BusinessType;
import com.lxmes.business.domain.CcHkInfo;
import com.lxmes.business.service.ICcHkInfoService;
import com.lxmes.common.utils.poi.ExcelUtil;
import com.lxmes.common.core.page.TableDataInfo;
import sun.security.util.SecurityConstants;

/**
 * 回款明细Controller
 * 
 * @author 王超
 * @date 2022-08-27
 */
@RestController
@RequestMapping("/business/hkinfo")
public class CcHkInfoController extends BaseController
{
    @Autowired
    private ICcHkInfoService ccHkInfoService;

    /**
     * 查询回款明细列表
     */
    @PreAuthorize("@ss.hasPermi('business:hkinfo:list')")
    @GetMapping("/list")
    public TableDataInfo list(CcHkInfo ccHkInfo)
    {
        startPage();
        List<CcHkInfo> list = ccHkInfoService.selectCcHkInfoList(ccHkInfo);
        return getDataTable(list);
    }

    /**
     * 导出回款明细列表
     */
    @PreAuthorize("@ss.hasPermi('business:hkinfo:export')")
    @Log(title = "回款明细", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, CcHkInfo ccHkInfo)
    {
        List<CcHkInfo> list = ccHkInfoService.selectCcHkInfoList(ccHkInfo);
        ExcelUtil<CcHkInfo> util = new ExcelUtil<CcHkInfo>(CcHkInfo.class);
        util.exportExcel(response, list, "回款明细数据");
    }

    /**
     * 获取回款明细详细信息
     */
    @PreAuthorize("@ss.hasPermi('business:hkinfo:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id)
    {
        return AjaxResult.success(ccHkInfoService.selectCcHkInfoById(id));
    }

    /**
     * 新增回款明细
     */
    @PreAuthorize("@ss.hasPermi('business:hkinfo:add')")
    @Log(title = "回款明细", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody CcHkInfo ccHkInfo)
    {
        ccHkInfo.setDeptId(SecurityUtils.getDeptId());
        return toAjax(ccHkInfoService.insertCcHkInfo(ccHkInfo));
    }

    /**
     * 修改回款明细
     */
    @PreAuthorize("@ss.hasPermi('business:hkinfo:edit')")
    @Log(title = "回款明细", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody CcHkInfo ccHkInfo)
    {
        ccHkInfo.setDeptId(SecurityUtils.getDeptId());
        return toAjax(ccHkInfoService.updateCcHkInfo(ccHkInfo));
    }

    /**
     * 删除回款明细
     */
    @PreAuthorize("@ss.hasPermi('business:hkinfo:remove')")
    @Log(title = "回款明细", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids)
    {
        return toAjax(ccHkInfoService.deleteCcHkInfoByIds(ids));
    }
}
